use crate::helpers::{Bot, Config};
use anyhow::{Context, Result};
use db::{/*models::MatrixOrTelegramId,*/ Db};
use teloxide::prelude::*;

// use super::get_user;
pub async fn count_unread_posts(bot: Bot, m: Message, db: Db, _config: Config) -> Result<()> {
    let user_id = m.from().context("NoneError")?.id;
    // let user = MatrixOrTelegramId::TelegramId { id: user_id, username: None };
    // let user = get_user_id(user, &db).await?;
    let unread_posts = db.count_unread_posts_db_tg(&user_id).await?;
    bot.send_message(user_id, format!("Unread posts: {}", unread_posts))
        .await?;
    Ok(())
}
